package cn.tedu.baidashi.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*配置静态资源映射*/
@Configuration
public class MyConfig implements WebMvcConfigurer {

    @Value("${resource.handler.path}")
    private String resourceHandler;
    @Value("${resource.locations.path}")
    private String resourceLocations;

    /*@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //映射图片保存地址
        registry.addResourceHandler("/image/**")
                .addResourceLocations("file:F:/GitRepository/baidashi/src/main/resources/static/image/");
    }*/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //映射图片保存地址
        registry.addResourceHandler(resourceHandler)
                .addResourceLocations(resourceLocations);
        System.out.println(resourceHandler);
    }
}
